package dsx.jsonTool;

import com.fasterxml.jackson.databind.ObjectMapper;


public class JsonTool {
	
	static ObjectMapper mapper = new ObjectMapper();
	
	public static String toString(Object obj) {
		try {
			String json = mapper.writeValueAsString(obj);
			return json;
		} catch (Exception ex) {
			return null;
		}
	}
	

	public static Object toObject(String json, Class<?> classType) {
		try {
			return mapper.readValue(json, classType);
		} catch (Exception ex) {
			return null;
		}
	}
	
}
